﻿using C1.WPF.FlexGrid;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SteelDetection
{
    /// <summary>
    /// PageMonitor.xaml 的交互逻辑
    /// </summary>
    public partial class PageMonitor : Page
    {
        public PageMonitor()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://192.168.1.192/");
        }
        private void ToggleButton_Click(object sender, RoutedEventArgs e)
        {
            e.Source = (e.Source as ToggleButton).Parent;
        }
    }

    public class NetStatusConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool && (bool)value == true)
            {
                return "正常";
            }
            else
                return "异常";
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return true;
        }
    }

    public class PowerStatusConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool && (bool)value == true)
            {
                return "正常";
            }
            else
                return "异常";
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return true;
        }
    }

    /// <summary>
    /// 文字颜色，正常状态白色，异常红色
    /// </summary>
    public class StatusColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            if (value is bool && (bool)value == true)
            {
                return new SolidColorBrush(Colors.White);
            }
            else
                return new SolidColorBrush(Colors.IndianRed);
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return true;
        }
    }
    public class Temp2Color : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string colorstr = "#FF00FF88";
            if ((float)value > 50)
                colorstr = "#FFFF003B";
            else if ((float)value > 40)
                colorstr = "#FFFFB300";


            return new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString(colorstr));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {

            return 0;

        }
    }

}
